<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.dao.ApartmentsDAO"%>
<%@page import="iwpl.project.entities.Apartments"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script type="text/javascript" src="Javascript/jquery-Validation.js"></script>
		<script type="text/javascript"
			src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>

		<title>Offices</title>
		<link href="CSS/CommonCSS.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
	$(document).ready(function() {
		$("#Offices").validate();
	});
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<link rel="stylesheet" href="css/CommonCSS.css" type="text/css" />
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'Update_Apartment.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	</head>

	<body>
		<form class="cmxform" id="commentForm" action="./servlet/Control_Apartment" method="get">


			<%
            	
            		int sStatus = 0;
            		String sApartID = "";
            		String sApartNumber="";
            		Integer sFloorNumber=0;
            		Double sValue= 0.0;
            		Integer sAreaID=0;
            		String sID = request.getParameter("id");
            		
            		ApartmentsDAO dao = new ApartmentsDAO();
            		Apartments apart = dao.findById(Integer.parseInt(sID));
            		
            		
            		sApartID = apart.getId().toString();
            		sAreaID = apart.getAreas().getId();
            		sApartNumber = apart.getApartmentNumber();
            		sFloorNumber = apart.getFloorNumber();
            		sValue = apart.getValue();
            		
            		
            		if(apart.getStatus())
            		{
            			sStatus = 1;
            		}
            		else
            		{
            			sStatus = 0;
            		}
            %>




			<style type="text/css">
label.error {
	float: none;
	color: red;
	padding-left: .5em;
	vertical-align: top;
}
</style>



			<tr>
				<td>
					<br />
				</td>
			</tr>
			<form id="form1" runat="server">
			<div align="center">	<h1>
												Update Apartment
									</h1>	</div>
									
				
				
									
					
					
						
									<table border="1" " align="center">
							<table width="285" border="0" height="277" align="center">
								<tbody>
									
									<tr>
										<td> 
											Apartment ID 
										</td>
										<td> 
											&nbsp;
											<input type="hidden" name="hiddenid" value="<%=sApartID%>" />
											<label><%=sApartID%></label>
										</td>
										
									</tr>
									<tr>
										<td> 
											Area ID 
										</td>
										<td>&nbsp;
											<select name="cboAreaID" style="width:150px">
			<%
				ApartmentsDAO objDao= new ApartmentsDAO();
				List<Apartments> lstOff = objDao.findAll();
				for( Iterator it = lstOff.iterator(); it.hasNext(); ) {
							Apartments apartment = (Apartments)it.next();
			 %> 				
			<option value="<%=apartment.getAreas().getId()%>" label="<%=sAreaID%>" /> 
			</option>
			<%} %>
			</select>
										</td>
										
									</tr>
									<tr>
										<td> 
											Apartment Number 
										</td>
										<td>
											&nbsp;
											
									<input type="text" name="txtApartmentNumber"
														class="required" value="<%=sApartNumber%>" />
													
										
									</tr>
									<tr>
										<td> 
											Floor Number 
										</td>
										<td>
											&nbsp;
											<input type="text" name="txtFloorNumber" class="required" value="<%=sFloorNumber%>" />
										</td>
										
									</tr>
									<tr>
										<td> 
											Value 
										</td>
										<td>
											&nbsp;
											<input type="text" name="txtValue" class="required" value="<%=sValue%>" />
										</td>
									
									</tr>
									<tr>
										<td> 
											Status 
										</td>
										<td>
											<%
							if (sStatus == 1) {
								out.println("<input type=\"checkbox\" name=\"chkStatus\"");
								out.println("checked=\"checked\" />");
							} else {
								out.println("<input type=\"checkbox\" name=\"chkStatus\" />");
							}
						%>
										</td>
										
									</tr>
									<tr>
										<td valign="top">
											<br />
										</td>
										<td valign="top">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<br />
										</td>
										
									</tr>
									<tr>
										<td valign="top">
											<input type="submit" value="Update" name="btnUpdate"
												class="submit" />
										</td>
										<td valign="top">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<input type="button" value="Back" name="btnBack"
												onClick="self.location='Manage_Apartment.jsp'" />
										</td>
										
									</tr>
								</tbody>
							</table>
							
						</table>	
					
					
				
				
			</form>
	</body>
</html>
